﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Game_Fly;
using System.Drawing;

namespace Game_Fly.Code.AuxiliaryAction
{
    public class PlaneDirection
    {
        public PlaneDirection()
        {

        }

        //左边边界限制
        public static void Left(ref int x, int speed, Image backGroundImage)
        {
            if (x >= (GameUI.GameForm.ClientSize.Width - backGroundImage.Width) / 2)//表示不可超出左边的边界
                x -= speed;
        }

        //右边边界限制
        public static void Right(ref int x, int speed, Image backGroundImage, int PlaneWidth)
        {
            if (x <= ((GameUI.GameForm.ClientSize.Width - backGroundImage.Width) / 2 + (backGroundImage.Width)) - (PlaneWidth - 5) - (PlaneWidth) / 2)//表示不可超出右边的边界,计算有可能不准确，所以添加了一点像素
                x += speed;
        }

        //上边边界限制
        public static void Up(ref int y, int speed)
        {
            if (y > 0)
                y -= speed;
        }

        //下边边界限制
        public static void Down(ref int y, int speed, int PlaneHeight)
        {
            if (y < GameUI.GameForm.ClientSize.Height - (PlaneHeight) - ((PlaneHeight / 2) - 5))
                y += speed;
        }
    }
}
